package com.dinzeer.foxextra.se;


import com.dinzeer.foxextra.regsiter.FEXSpecialEffectsRegistry;
import com.dinzeer.legendreliclib.lib.compat.slashblade.SwordRainGenerator;
import com.dinzeer.legendreliclib.lib.compat.slashblade.entity.swordrain.BaseSwordRainEntity;
import mods.flammpfeil.slashblade.capability.slashblade.ISlashBladeState;
import mods.flammpfeil.slashblade.event.SlashBladeEvent;
import mods.flammpfeil.slashblade.registry.specialeffects.SpecialEffect;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

import java.util.List;

@Mod.EventBusSubscriber
public class SummonSword extends SpecialEffect {
    public SummonSword() {
        super(60,false,false);
    }
    @SubscribeEvent
    public static void onDoingSlash(SlashBladeEvent.DoSlashEvent event) {
        ISlashBladeState state = event.getSlashBladeState();
        if (state.hasSpecialEffect(FEXSpecialEffectsRegistry.SummonSword.getId())) {
            if (!(event.getUser() instanceof Player)) {
                return;
            }

            Player player = (Player)event.getUser();
            RandomSource random = player.getRandom();
            int level = player.experienceLevel;
            if (SpecialEffect.isEffective(FEXSpecialEffectsRegistry.SummonSword.get(), level)) {
                List<BaseSwordRainEntity> BaseSwordRains= SwordRainGenerator.generateFivePointSwordRain(event.getUser(), event.getUser().level(),5);
                for(BaseSwordRainEntity swordRain : BaseSwordRains) {
                    swordRain.setColor(16777215);
                    swordRain.setDelay(random.nextInt(10));
                }

            }
        }

    }
}
